---
import Layout from '@layouts/Layout.astro';
import SectionList from '@components/things/SectionList.astro';
import Main from '@components/scafold/MainCard.astro';
import { fetchData, slugify } from '@utils/fetch-data';
import type { Section } from '../types/Service';
import Button from '@components/form/Button.astro';
interface Props {
title: string;
sections: Section[];
}
const { title, sections } = Astro.props;
const categories = (await fetchData()).categories;
export async function getStaticPaths() {
const pages = await fetchData().then((data) => {
return data.categories.map((category) => {
return {
category: slugify(category.name),
title: category.name,
sections: category.sections,
};
});
});
return pages.map(({ category, title, sections }) => {
return {
params: { category },
props: { title, sections },
};
});
}
const makePaginationLinks = () => {
const index = categories.findIndex(category => category.name === title);
const previousCategory = index > 0 ? categories[index - 1].name : null;
const nextCategory = index < categories.length - 1 ? categories[index + 1].name : null;
return { previous: previousCategory, next: nextCategory };
};
const { previous, next } = makePaginationLinks();
---
Browse All